package com.ftg.learn.util.page;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.List;

/**
 * 基于mybatisplus的自定义多表查询分页功能
 *
 * @author kangjx
 * @version 1.0
 * @date 2023/5/9 下午3:35
 */
@Mapper
public interface PageMapperUtil<VO> {

    /**
     * 直接写sql
     * @param sql  select * from a left join b on a.id =b.id left join c on c.id = b.id
     * @param ipage
     * @return
     */
    @SelectProvider(method = "initPageSql",type = SqlDeep.class)
    public List<VO> showReport(@Param("sql") String sql, IPage<VO> ipage);

    @SelectProvider(method = "countPageSql",type = SqlDeep.class)
    public long countReport(@Param("sql") String sql);

    @SelectProvider(method = "initPageSql",type = SqlDeep.class)
    public List<VO> showReport1(@Param("sql") String sql, @Param(Constants.WRAPPER) Wrapper wrapper, IPage<VO> ipage);

    @SelectProvider(method = "countPageSql",type = SqlDeep.class)
    public long countReport1(@Param("sql") String sql,@Param(Constants.WRAPPER) Wrapper wrapper);

}
